package Leetcode;

import java.util.Arrays;

public class Leetcode_283 {
    public static int minMovesToSeat(int[] seats, int[] students) {
        Arrays.sort(seats);
        Arrays.sort(students);
        int res = 0;
        for (int i = 0; i < seats.length; i++) {
            res += Math.abs(seats[i] - students[i]);
        }
        return res;
    }

    public static void main(String[] args) {
        int[] seats = {3,1,5}, students = {2,7,4};
        System.out.println(minMovesToSeat(seats,students));
    }
}
